package com.example.mapper;

import com.example.pojo.Clazz;
import com.example.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ClazzMapper {


    /**
     * 分页查询所有班级
     * @return
     */
    List<Clazz> page(ClazzQueryParam clazzQueryParam);

    /**
     * 根据Id删除班级信息
     * @param id
     */
    @Delete("delete from clazz where id = #{id}")
    void deleteById(Integer id);

    /**
     * 新增班级信息
     * @param clazz
     */
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject, create_time, update_time) " +
            "values(#{name},#{room},#{beginDate},#{endDate}, #{masterId},#{subject}, #{createTime}, #{updateTime})")
    void save(Clazz clazz);

    /**
     * 根据Id查询班级信息
     * @param id
     * @return
     */

    Clazz findById(Integer id);

    /**
     * 修改班级信息
     * @param clazz
     */
    @Update("update clazz set name = #{name},room = #{room},begin_date = #{beginDate},end_date = #{endDate},master_id = #{masterId},subject = #{subject},update_time = #{updateTime} where id = #{id}")
    void update(Clazz clazz);

    /**
     * 查询所有班级信息
     * @return
     */

    List<Clazz> list();
}
